import request from '@/utils/request'


export function roleList(query) {
  return request({
    url: '/api/roles',
    method: 'get',
    params: query
  })
}

export function addRole(data) {
  return request({
    url: '/api/roles?name='+data,
    method: 'post',
    
  })
}

export function updateRole(id,data) {
  return request({
    url: `/api/roles/name/${id}`,
    method: 'patch',
    
    data
  })
}
// PATCH /api/roles/state/
export function updateRoleState(id,data) {
  return request({
    url: `/api/roles/state/${id}?state=`+data,
    method: 'patch',
    // data
  })
}
// /api/roles/role_permission/{
  export function updateRolePermission(id, data) {
    return request({
      url: `/api/roles/role_permission/${id}`,
      method: 'post',
      data
    })
  }
  // DELETE /api/roles/
export function deleteRole(id) {
  return request({
    url: `/api/roles/${id}`,
    method: 'delete'
  })
}

export function getRoleById(id){
  return request({
    url:`/api/roles/${id}`,
    method:'get'
  })
}